package com.lanqiaofinal11;

import java.util.ArrayDeque;
import java.util.Queue;

/**
 * @author `RKC`
 * @date 2022/6/17 9:19
 */
public class B扩散 {

    private static final int BASE = 2500;
    private static final int[][] dirs = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
    private static boolean[][] st = new boolean[8000][8000];
    private static Queue<int[]> q = new ArrayDeque<>();

    public static void main(String[] args) {
        q.add(new int[]{get(0), get(0)});
        q.add(new int[]{get(2020), get(11)});
        q.add(new int[]{get(11), get(14)});
        q.add(new int[]{get(2000), get(2000)});
        int k = 0;
        while (!q.isEmpty()) {
            int size = q.size();
            for (int i = 0; i < size; i++) {
                int[] cur = q.poll();
                int x = cur[0], y = cur[1];
                if (st[x][y]) continue;
                st[x][y] = true;
                for (int[] dir : dirs) {
                    int nx = x + dir[0], ny = y + dir[1];
                    if (st[nx][ny]) continue;
                    q.add(new int[]{nx, ny});
                }
            }
            if (k == 2020) break;
            k++;
        }
        int ans = 0;
        for (int i = 0; i < 8000; i++) {
            for (int j = 0; j < 8000; j++) {
                if (st[i][j]) ans++;
            }
        }
        System.out.println(ans);
    }

    private static int get(int x) {
        return BASE + x;
    }
}
